package com.lcm.algorithm.datatest.array.slidWindow;

import java.util.HashMap;
import java.util.Map;

/**
 * @description:
 * @author: lcm
 * @create: 2020-04-05 11:53
 **/

public class MinWindow {

    public static void main(String[] args){
        System.out.println(minWindow("ADOBECODEBANC","ABC"));
    }

    public static String minWindow(String s, String t) {
        StringBuilder sb=new StringBuilder();
        Map<Character,Integer> map=new HashMap<>();
        for(int i=0;i<t.length();i++){
            map.put(t.charAt(i),0);
        }
        int count=0;
        int i=0;

        for(;i<s.length();i++){
            if (map.containsKey(s.charAt(i))){
                map.put(s.charAt(i),1);
                count++;
                sb.append(s.charAt(i));
                break;
            }
        }


        return count==t.length()?sb.toString():"";
    }

}
